package cn.kgc.service.impl;

import cn.kgc.dao.UserDao;
import cn.kgc.dto.Dto;
import cn.kgc.entity.DmUser;
import cn.kgc.service.UserService;
import cn.kgc.utils.DtoUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author:limengxian
 * @Date:Created in 2020/11/23 14:20
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;
    /**
     * 登录
     * @param phone
     * @param password
     * @return
     */
    @Override
    public Dto login(String phone, String password, HttpServletRequest request) {
        //根据账号和密码查询用户信息
        DmUser dmUser = userDao.queryUserByPhoneAndPassword(phone, password);
        //生成token
        String userAgent = request.getHeader("user-agent");
        return DtoUtil.returnDataSuccess(dmUser);
    }
}
